/*******************************************************************************
 * Copyright (c) 2012 AwOiSoAk.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     $AwOiSoAk - initial API and implementation
 ******************************************************************************/
package com.awoisoak.dundeeguide;


import com.madsa.AugmentedCompass.BrujulaAumentada;

import android.app.Activity;
import android.content.Intent;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;


public class Attraction extends Activity implements OnClickListener{
	String coordinate = null;
	String place = null;
	int explanation = 0;
	int iconPlace = 0;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.attraction);
		
		TextView tvAttraction= (TextView)findViewById(R.id.tvAttraction);
		TextView tvExplanation= (TextView)findViewById(R.id.tvExplanation);
		
		//Button btPictures = (Button)findViewById(R.id.btPictures);
		//Button btMap = (Button)findViewById(R.id.btMap);
		
		ImageButton iBtPictures = (ImageButton)findViewById(R.id.iBtPictures);
		ImageButton iBtMap = (ImageButton)findViewById(R.id.iBtMap);
		ImageButton iBtCompass = (ImageButton)findViewById(R.id.iBtCompass);
				
		iBtMap.setOnClickListener(this);
		iBtPictures.setOnClickListener(this);
		iBtCompass.setOnClickListener(this);
		Bundle extras = getIntent().getExtras();

			if (extras!= null){ 
				
				coordinate = extras.getString("tag_coordinate");
				place = extras.getString("tag_place");
				explanation = extras.getInt("tag_explanation");
				iconPlace = extras.getInt("tag_icon");

				tvAttraction.setText(place);
				tvExplanation.setText(explanation);

			}

		}

	@Override
	public void onClick(View v) {
		Intent i;
		
		//We apply a filter to the button when it's pressed
		((ImageView) v).setColorFilter(0xFF00FFFF, PorterDuff.Mode.MULTIPLY);
		int BUTTON = v.getId();
		
		switch (BUTTON){
			case R.id.iBtPictures:
				i = new Intent(Attraction.this,MyGallery.class);
				i.putExtra("tag_place", place);

				startActivity(i);
				break;
			case R.id.iBtMap:
				i = new Intent (Attraction.this,Map.class);
				i.putExtra("tag_place",place);
				i.putExtra("tag_coordinate", coordinate);
				startActivity(i);
				break;
			case R.id.iBtCompass:
				i = new Intent (Attraction.this,BrujulaAumentada.class);
				i.putExtra("destineDescription",  "    "+place);
				i.putExtra("destineLocation", coordinate);
				i.putExtra("imageName","ar_destino");
				startActivity(i);
				break;	
		}
	}

	@Override
	protected void onResume() {
		
		//We clear the filters applied on the buttons (if they were set)
		ImageButton iBtPictures = (ImageButton)findViewById(R.id.iBtPictures);
		ImageButton iBtMap = (ImageButton)findViewById(R.id.iBtMap);
		ImageButton iBtCompass = (ImageButton)findViewById(R.id.iBtCompass);

		((ImageView) iBtPictures).clearColorFilter();
		((ImageView) iBtMap).clearColorFilter();
		((ImageView) iBtCompass).clearColorFilter();
		super.onStart();
	}

	
	
	
	
	
}
